/* 
 * File:   Math.h
 * Author: jcrada
 *
 * Created on August 28, 2008, 4:41 PM
 */

#ifndef _MATH_H
#define	_MATH_H
#include <LinearMath/btVector3.h>
#include <gsl/gsl_math.h>
#include <QtCore/QRect>

namespace jcrada {

    class Math {
    public:

        enum eAxis {
            X = 0, Y, Z
        };

        enum ePlane {
            XY = 0, YZ, ZX, PLANE_COUNT,
        };
    public:
        static double scaleParma( double src_min, double src_max, double vale, double target_min, double target_max);
        static double scale( double src_min, double src_max, double src_val, double target_min, double target_max );
        static double abs( double value );
        static double sigmoid( double value );
        static void copy( int size, const double *src, double *target );
        //        modEuclidean siempre es positivo
        static long modEuclidean( long D, long d );
        //Ni idea éste, pero tiene negativos y varios valores son diferentes de %
        static long modFloor( long D, long d );
        //        static long scaleLong(long src_min, long src_max, long src_val, long target_min, long target_max);
        static int binToInt( double const *bin, int size );
        static void fillBinaryInputs( double **inputs, int input_size );

        static double degToRad( double degrees );
        static double radToDeg( double radians );

        static double getAngleInRadians( ePlane plane, const btVector3& a, const btVector3& b );
        static double getAngleInDegrees( ePlane plane, const btVector3& a, const btVector3& b );
        static double getGradient( ePlane plane, const btVector3& a, const btVector3& b );
        
        static void cartesianToSpherical(const btVector3& coord, double& radial, double& azimuth, double& zenith);

        //A/a = B/b = H/h
        static double triangleFunction( const double A, const double B, const double b){
            assert(B > 0);
//            double H = sqrt(gsl_pow_2(A) + gsl_pow_2(B));
//            return b * H / B;
            return B / (A * b);
        }
        static void centerInDesktop( const int width, const int height, int& pos_x, int& pos_y);
        static QRect centerInDesktop( const QRect& rect);
        

        static int test( int argc, char** argv );
    };
}

#endif	/* _MATH_H */

